import Vue from 'vue';
import App from './App.vue';
import router from './router';
import ElementUI from 'element-ui';
//import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
import './assets/css/theme-green/index.css'; // 浅绿色主题
import './assets/css/icon.css';
import './components/common/directives';
import 'babel-polyfill';
import './assets/css/my.css';
import axios from 'axios'
Vue.prototype.$axios = axios
axios.defaults.withCredentials = true;
axios.defaults.headers['Access-Control-Allow-Origin'] = 'http://localhost:8083/';
// axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded';

Vue.config.productionTip = false;
Vue.use(ElementUI, {
    size: 'small'
});

// 使用钩子函数对路由进行权限跳转
router.beforeEach((to, from, next) => {
    document.title = `${to.meta.title} | vue-manage-system`;
    const role = localStorage.getItem('telephone');
    if (!role && to.path !== '/u_login' && to.path !== '/login' && to.path !== '/judge' && to.path !== '/' && to.path !== '/dashboard' && to.path !== '/u_regist') {
        next('/judge');
    }  else {
        next();
    }
});

new Vue({
    router,
    render: h => h(App)
}).$mount('#app');







